/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entite;

import connexion.Connexion;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.ArrayList;

/**
 *
 * @author asall
 */
public class Coresponsable {
    
    static Connexion con= new Connexion();
	public String numHar;
	public String nom;
	public String prenom;
	public String codeUfr;
	public String libelleLongUfr;
	public String libelleCourtUfr;
 
  public Coresponsable(String numHar,String nom,String prenom,String codeUfr,String libelleLongUfr, String libelleCourtUfr){
        this.numHar=numHar;
	this.nom=nom;
	this.prenom=prenom;
	this.codeUfr=codeUfr;
	this.libelleLongUfr=libelleLongUfr;
	this.libelleCourtUfr=libelleCourtUfr;
}
  public Coresponsable(){}
  public ArrayList<Coresponsable> listeCoresponsable(int idDiplome){

       ArrayList<Coresponsable> coresponsable= new ArrayList<Coresponsable>();  
       

	String numHar=" num harpege coresponsable ";
	String nom="nom coresponsable";
	String prenom="prenom coresponsable";
	String codeUfr="code ufr coresponsable";
	String libelleLongUfr="libelle ufr coresponsable";
	String libelleCourtUfr="libelle court coresponsable";
	
	//Pour tester(à enlever après)
	Coresponsable coresp= new Coresponsable(numHar,nom,prenom,codeUfr,libelleLongUfr,libelleCourtUfr);
        coresponsable.add(coresp);

	try {
		Statement req = con.getInstance().createStatement();

                ResultSet resultatDest = req.executeQuery("select per.num_harpege, per.nom, per.prenom,cp.code_apogee,"
                        + " cp.libelle_long,cp.libelle_court"
                        + " from diplome di, coresponsable coresp, personnel per, composante cp"
                        + " where di.id_dip=coresp.fid_dip and coresp.fid_pers=per.id_pers"
                        + " and cp.id_comp=per.fid_comp and di.id_dip= "+ idDiplome );

        	while (resultatDest.next()) {
		numHar=(resultatDest.getString("num_harpege"));
		nom=(resultatDest.getString("nom"));		
		prenom=(resultatDest.getString("prenom"));		
                codeUfr=(resultatDest.getString("code_apogee"));
		libelleLongUfr=(resultatDest.getString("libelle_long"));
		libelleCourtUfr=(resultatDest.getString("libelle_court"));
		
		coresp= new Coresponsable(numHar,nom,prenom,codeUfr,libelleLongUfr,libelleCourtUfr);
		coresponsable.add(coresp);
		}

		} 
	     catch (Exception e) {

			e.printStackTrace();
		}
          
	
       return coresponsable;
}
}
